package com.itlong.cloud.POJO.PO;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.itlong.cloud.annotation.ItlField;
import com.itlong.cloud.annotation.ItlTables;
import com.itlong.cloud.enumerate.SmartCommunityEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;


/**
 *
 * <desc>
 *      云对讲--业务变更点通知
 * </desc>
 *
 * @createDate 2017/09/20
 */
@ItlTables("device_business_change_log")
@Data
@NoArgsConstructor()
@EqualsAndHashCode(callSuper=true)
public class DeviceBusinessChangeLogPO extends BasePO implements Serializable {

    @ItlField("command_type")
    private Integer commandType;     //业务指令，业务指令，1-项目信息，2-用户与项目，3-设备信息，4-房间信息，5-用户与房间，6-多媒体信息，7-房间全量，8-云对讲业务服务器变更，
                                     //9-云对讲单个设备物理地址变更，10-更人脸信息变

    @ItlField("command_parameter")
    private String commandParameter;  //业务指令参数

    @ItlField("command_des")
    private String commandDes; //
    @ItlField("project_id")
    private String projectId; //项目编号

    /**
     * <desc>
     *     云对讲业务变更点通知
     * </desc>
     * @param smartCommunityEnum
     * @param commandParameter  String格式的JSON数据
     */
    public DeviceBusinessChangeLogPO(SmartCommunityEnum smartCommunityEnum,String commandParameter,String projectId) {
        this.commandType = smartCommunityEnum.getCommandType();
        this.commandDes = smartCommunityEnum.getCommandDes();
        this.commandParameter = commandParameter;
        this.projectId = projectId;
    }

    /**
     * <desc>
     *     云对讲业务变更点通知
     * </desc>
     * @param commandParameterJS   JSONObject格式数据
     * @param smartCommunityEnum
     */
    public DeviceBusinessChangeLogPO(SmartCommunityEnum smartCommunityEnum,JSONObject commandParameterJS,String projectId) {
        this.commandType = smartCommunityEnum.getCommandType();
        this.commandDes = smartCommunityEnum.getCommandDes();
        this.commandParameter = JSONObject.toJSONString(commandParameterJS);
        this.projectId = projectId;
    }

    /**
     * <desc>
     *     云对讲业务变更点通知
     * </desc>
     * @param smartCommunityEnum
     * @param commandParameterJSArr JSONArray格式数据
     */
    public DeviceBusinessChangeLogPO(SmartCommunityEnum smartCommunityEnum,JSONArray commandParameterJSArr,String projectId) {
        this.commandType = smartCommunityEnum.getCommandType();
        this.commandDes = smartCommunityEnum.getCommandDes();
        this.commandParameter = JSONObject.toJSONString(commandParameterJSArr);
        this.projectId = projectId;
    }
}